package com.wmlive.hhvideo.heihei.mainhome.presenter;

import com.wmlive.hhvideo.common.base.BasePresenter;
import com.wmlive.hhvideo.common.network.HttpConstant;
import com.wmlive.hhvideo.heihei.beans.main.AttentionResponse;
import com.wmlive.hhvideo.heihei.beans.main.UpdateInfo;
import com.wmlive.hhvideo.heihei.beans.splash.InitCatchData;
import com.wmlive.hhvideo.heihei.mainhome.view.MainActivityView;
import com.wmlive.networklib.entity.DCNetObserver;


/**
 * 检测系统升级
 * Created by kangzhen on 2017/6/16.
 */

public class UpdatePresenter  extends BasePresenter<MainActivityView> {

    public UpdatePresenter(MainActivityView view) {
        super(view);
    }

    /**
     *  检查更新
     * @param version
     * @param channel
     */
    public void checkSystemAppUpdate(String version,String channel){
        executeRequest(HttpConstant.TYPE_CHECK_SYSTEM_UPLOAD_CODE, getHttpApi().checkSystemAppUpdate(InitCatchData.sysUpdateCheck(), version,"android","app_name",channel))
                .subscribe(new DCNetObserver<UpdateInfo>(){
                    @Override
                    public void onRequestDataReady(int requestCode, String message, UpdateInfo response) {
                            if (viewCallback!=null){
                                viewCallback.checkSystemAppUpdateSucceed(response);
                            }
                    }

                    @Override
                    public void onRequestDataError(int requestCode, int serverCode, String message) {
                        if (viewCallback!=null){
                            viewCallback.checkSystemAppUpdateFailure(message);
                        }
                    }
                });
    }
}
